/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dto;

import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import exceptions.EventException;
import java.util.ResourceBundle;

/**
 * An image event
 * 
 * @author steffen
 */
@DatabaseTable(tableName = "image_event")
public class ImageEvent extends Event {
    
    private static final String IMAGE_ID_FIELD_NAME = "image_id";
    private static final String IMAGE_FIELD_NAME = "image";
    
    private static final String IMAGE_EMPTY = "imageempty"; // key for resourcebundle
    
    @DatabaseField(columnName = IMAGE_FIELD_NAME, dataType = DataType.SERIALIZABLE)
    private Image image;

    public ImageEvent() {
        super();
    } // Needed for OrmLite
    
    /**
     * Creates a new ImageEvent
     * 
     * @param track the track the event belongs to
     * @param description a descrption (name) of the event
     * @param timestamp the timestamp when the event happened
     * @param pos the position of the event
     * @param image the image this event represents
     * @throws EventException 
     */
    public ImageEvent (Track track, String description, long timestamp, GeoPoint pos, Image image) throws EventException {
        super(track, description, timestamp, pos);
        
        setImage(image);
    }
    
    
    public Image getImage() {
        return image;
    }

    public void setImage(Image image) {
        if (image == null) throw new IllegalArgumentException(ResourceBundle.getBundle("gui/guilabels").getString(IMAGE_EMPTY));
        this.image = image;
    }
    
}
